function [voting_table, pre_labels, recognition_ratio] = svm(Training_Samples, Testing_Samples, Training_Labels, Testing_Labels)

%train set [-1, 1]
%The best accuracy: 29.2562, c=8, gamma=0.025.
%first max: accuracy = 51.9481; last max: accuracy = 51.4286

%train set [0, 1]
%The best accuracy: 29.2562, c=8, gamma=0.1.
%first max: accuracy = 51.9481; last max: accuracy = 51.4286

Gamma = 0.1;
C = 8;

[train_intervals, train_class_sizes, train_class_count] = split(Training_Labels);
test_rows = size(Testing_Samples, 1);

voting_table = zeros(test_rows, train_class_count);
pre_labels = zeros(test_rows, 1);

Testing_Samples = Testing_Samples';
Testing_Labels = Testing_Labels';
for i = 1:1:train_class_count,
    for j = i+1:1:train_class_count,
        if j~=i,
            data_inst_window = [Training_Samples(train_intervals(i,1):train_intervals(i,2),:);Training_Samples(train_intervals(j,1):train_intervals(j,2),:)];
            data_label_window = [Training_Labels(train_intervals(i,1):train_intervals(i,2),:);Training_Labels(train_intervals(j,1):train_intervals(j,2),:)];
            [AlphaY, SVs, Bias, Parameters, nSV, nLabel] = RbfSVC(data_inst_window', data_label_window', Gamma, C);
            [ClassRate, DecisionValue, Ns, ConfMatrix, PreLabels] = SVMTest(Testing_Samples, Testing_Labels, AlphaY, SVs, Bias, Parameters, nSV, nLabel);;
            for z = 1:1:test_rows,
                if DecisionValue(z) > 0,
                    voting_table(z, PreLabels(z)) = voting_table(z, PreLabels(z)) + 1;
                else
                    voting_table(z, PreLabels(z)) = voting_table(z, PreLabels(z)) + 1;
                end
            end
        end
    end
end

matches = 0;
for d = 1:1:test_rows,
    row = voting_table(d:d,:);
    max_row_el = max(row);
    ind = find(row>=max_row_el, 1, 'first');
    pre_labels(d, 1) = ind;
    if ind == Testing_Labels(d),
        matches = matches + 1;
    end
end

recognition_ratio = (matches/test_rows)*100;

end